package org.bwf.study.controller;

import io.swagger.annotations.ApiOperation;
import org.bwf.obj.bo.UserLoginBO;
import org.bwf.obj.bo.UserRegisterBO;
import org.bwf.study.aop.ReturnInfo;
import org.bwf.study.servcie.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/users/")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "用户注册接口")
    @PutMapping
    public Object Register(UserRegisterBO bo){
        return new ReturnInfo(userService.Register(bo));
    }

    @ApiOperation(value = "用户登录接口")
    @PostMapping
    public Object Login(@Validated UserLoginBO bo) {
        return new ReturnInfo(userService.Login(bo));
    }
}
